<?php
namespace App\Admin\Controllers\System\Traits;

use App\Wen\Utils\Settings;

trait manifestJsonTrait{
    function get_manifest_json_content(){
        if(_empty_(Settings::get('uni_appid', ''))){
            exit('请先配置manifest.json文件Uni-App应用标识，并提交保存');
        }
        return '
        {
    "name" : "'.Settings::get('uni_name', '').'",
    "appid" : "'.Settings::get('uni_appid', '').'",
    "description" : "'.Settings::get('uni_description', '').'",
    "versionName" : "'.get_mini_version_code().'",
    "versionCode" : 1,
    "transformPx" : false,
    "app-plus" : {
        "usingComponents" : true,
        "darkmode" : true,
        "nvueStyleCompiler" : "uni-app",
        "compilerVersion" : 3,
        "compatible": {
			"ignoreVersion": true
		},
        "splashscreen" : {
            "alwaysShowBeforeRender" : true,
            "waiting" : true,
            "autoclose" : true,
            "delay" : 0
        },
        "screenOrientation" : [
            "portrait-primary",
            "portrait-secondary",
            "landscape-primary",
            "landscape-secondary"
        ],
        "modules" : {
            "OAuth" : {},
            "Payment" : {},
            "VideoPlayer" : {},
            "Share" : {},
            "Geolocation" : {},
            "Maps" : {},
            "Camera" : {},
            "Record" : {},
            "Push" : {},
            "Barcode" : {}
        },
        "safearea" : {
            "bottom" : {
                "offset" : "none"
            }
        },
        "distribute" : {
            "android" : {
                "permissions" : [
                    "<uses-feature android:name=\"android.hardware.camera\"/>",
                    "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
                    "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
                    "<uses-permission android:name=\"android.permission.CAMERA\"/>",
                    "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
                    "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
                    "<uses-permission android:name=\"android.permission.INSTALL_PACKAGES\"/>",
                    "<uses-permission android:name=\"android.permission.INTERNET\"/>",
                    "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
                    "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
                    "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
                    "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
                    "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
                    "<uses-permission android:name=\"android.permission.REQUEST_INSTALL_PACKAGES\"/>",
                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
                    "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
                    "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
                    "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
                ],
                "schemes" : "'.Settings::get('admin_app_url_schemes', 'chongyeapp').'",
                "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
                "minSdkVersion" : 28,
				"targetSdkVersion" : 33
            },
            "ios" : {
                "dSYMs" : false,
                "urltypes" : "'.Settings::get('admin_app_url_schemes', 'chongyeapp').'",
                "privacyDescription" : {
                    "NSPhotoLibraryUsageDescription" : "用于发布笔记时选取图片",
                    "NSPhotoLibraryAddUsageDescription" : "用于保存生成的海报等",
                    "NSCameraUsageDescription" : "扫一扫，发布笔记选择图片，视频等",
                    "NSMicrophoneUsageDescription" : "录音，聊天时发送语音文件",
                    "NSUserTrackingUsageDescription" : "请放心，开启权限不会获取您在其他站点的隐私信息，该权限仅用于标识设备并保障服务安全与提示浏览体验",
                    "NSLocationWhenInUseUsageDescription" : "用于发布笔记时添加位置，让更多的同地域的人看见你的笔记",
                    "NSLocationAlwaysAndWhenInUseUsageDescription" : "用于发布笔记时添加位置，让更多的同地域的人看见你的笔记",
                    "NSSpeechRecognitionUsageDescription" : "聊天时发布语音",
                    "NSLocationAlwaysUsageDescription" : "用于定位，获取附件的笔记"
                },
                "capabilities" : {
                    "entitlements" : {
                        "com.apple.developer.associated-domains" : [ "applinks:'.str_replace(['https://', 'http://'], '', env('APP_URL', '')).'" ]
                    }
                },
                "idfa" : true
            },
            "sdkConfigs" : {
                "oauth" : {
                    "weixin" : {
                        "appid" : "'.Settings::get('app_app_id', '').'",
                        "UniversalLinks" : "'.env('APP_URL').'/sdksample/"
                    },
                    "apple" : {}
                },
                "payment" : {
                    "weixin" : {
                        "__platform__" : [ "ios", "android" ],
                        "appid" : "'.Settings::get('app_app_id', '').'",
                        "UniversalLinks" : "'.env('APP_URL').'/sdksample/"
                    },
                    "appleiap" : {},
                    "alipay" : {
                        "__platform__" : [ "ios", "android" ]
                    }
                },
                "ad" : {},
                "share" : {
                    "weixin" : {
                        "appid" : "'.Settings::get('app_app_id', '').'",
                        "UniversalLinks" : "'.env('APP_URL').'/sdksample/"
                    }'.(!_empty_(Settings::get('app_qq_app_appid')) ? ',
                    "qq" : {
                        "appid" : "'.Settings::get('app_qq_app_appid').'",
                        "UniversalLinks" : "'.env('APP_URL').'/qq_conn/'.Settings::get('app_qq_app_appid').'"
                    }' : '').(!_empty_(Settings::get('app_weibo_app_appid')) ? ',
                    "sina" : {
                        "appkey" : "'.Settings::get('app_weibo_app_appid').'",
                        "redirect_uri" : "'.env('APP_URL').'?type=weibo",
                        "UniversalLinks" : "'.env('APP_URL').'/sdksample/"
                    }' : '').'
                },
                "geolocation" : {
                    "amap" : {
                        "__platform__" : [ "ios", "android" ],
                        "appkey_ios" : "'.Settings::get('app_gaode_appkey_ios', '').'",
                        "appkey_android" : "'.Settings::get('app_gaode_appkey_android', '').'"
                    },
                    "system" : {
                        "__platform__" : [ "ios", "android" ]
                    }
                },
                "maps" : {
                    "amap" : {
                        "appkey_ios" : "'.Settings::get('app_gaode_appkey_ios', '').'",
                        "appkey_android" : "'.Settings::get('app_gaode_appkey_android', '').'"
                    }
                },
                "push" : {
                    "unipush" : {}
                }
            },
            "icons" : {
                "android" : {
                    "hdpi" : "unpackage/res/icons/72x72.png",
                    "xhdpi" : "unpackage/res/icons/96x96.png",
                    "xxhdpi" : "unpackage/res/icons/144x144.png",
                    "xxxhdpi" : "unpackage/res/icons/192x192.png"
                },
                "ios" : {
                    "appstore" : "unpackage/res/icons/1024x1024.png",
                    "ipad" : {
                        "app" : "unpackage/res/icons/76x76.png",
                        "app@2x" : "unpackage/res/icons/152x152.png",
                        "notification" : "unpackage/res/icons/20x20.png",
                        "notification@2x" : "unpackage/res/icons/40x40.png",
                        "proapp@2x" : "unpackage/res/icons/167x167.png",
                        "settings" : "unpackage/res/icons/29x29.png",
                        "settings@2x" : "unpackage/res/icons/58x58.png",
                        "spotlight" : "unpackage/res/icons/40x40.png",
                        "spotlight@2x" : "unpackage/res/icons/80x80.png"
                    },
                    "iphone" : {
                        "app@2x" : "unpackage/res/icons/120x120.png",
                        "app@3x" : "unpackage/res/icons/180x180.png",
                        "notification@2x" : "unpackage/res/icons/40x40.png",
                        "notification@3x" : "unpackage/res/icons/60x60.png",
                        "settings@2x" : "unpackage/res/icons/58x58.png",
                        "settings@3x" : "unpackage/res/icons/87x87.png",
                        "spotlight@2x" : "unpackage/res/icons/80x80.png",
                        "spotlight@3x" : "unpackage/res/icons/120x120.png"
                    }
                }
            },
            "splashscreen" : {
                "useOriginalMsgbox" : true,
                "iosStyle" : "'. (file_exists(public_path('storage/splashscreen/storyboard.zip')) ? 'storyboard' : 'common') .'",
                "ios" : {
                    "storyboard" : "unpackage/res/splashscreen/storyboard.zip"
                },
                "androidStyle" : "'. (file_exists(public_path('storage/splashscreen/480_762.9.png')) ? 'default' : 'common') .'",
                "android" : {
                    "hdpi" : "unpackage/res/splashscreen/480_762.9.png",
                    "xhdpi" : "unpackage/res/splashscreen/720_1242.9.png",
                    "xxhdpi" : "unpackage/res/splashscreen/1080_1882.9.png"
                }
            }
        }
    },
    "quickapp" : {},
    "mp-weixin" : {
        "darkmode" : true,
        "appid" : "'.Settings::get('app_id', '').'",
        "setting" : {
            "urlCheck" : false
        },
        "usingComponents" : true,
        "permission" : {
            "scope.userLocation" : {
                "desc" : "你的位置信息将用于小程序位置接口的效果展示"
            }
        },
        "plugins" : {},
        "requiredBackgroundModes" : [ "audio", "location" ],
        "optimization" : {
            "subPackages" : true
        },
        "requiredPrivateInfos": [
		    "getLocation",
		    "onLocationChange",
		    "startLocationUpdateBackground",
		    "chooseAddress",
		    "chooseLocation"
		],
        "singlePage" : {
            "navigationBarFit" : "float"
        },
        "componentPlaceholder" : {
			"my-toast": "view",
			"hover-ball": "view",
            "mp-html" : "view",
            "mini-upload-img" : "view"
        }
    },
    "mp-alipay" : {
        "usingComponents" : true
    },
    "mp-baidu" : {
        "usingComponents" : true
    },
    "mp-toutiao" : {
        "usingComponents" : true
    },
    "uniStatistics" : {
        "enable" : false
    },
    "vueVersion" : "2"
}

        ';
    }
}
